package com.turnengine.client.global.game.command;

import com.javabi.command.IExecutableCommand;
import com.javabi.command.IExecutableCommandResponse;
import com.javabi.command.serializer.AbstractCommandDataSerializer;
import com.javabi.common.io.data.IDataReader;
import com.javabi.common.io.data.IDataWriter;
import com.turnengine.client.global.game.bean.GameInstanceSerializer;
import com.turnengine.client.global.game.bean.IGameInstance;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * The Get Game Instances Data Serializer.
 */
public class GetGameInstancesDataSerializer extends AbstractCommandDataSerializer<List<IGameInstance>> implements IGetGameInstancesDataSerializer {

	/**
	 * Creates a new Get Game Instances Data Serializer.
	 */
	public GetGameInstancesDataSerializer() {
		super(GetGameInstances.COMMAND_ID);
	}

	@Override
	public List<IGameInstance> readReturnValue(IDataReader reader) throws IOException {
		List<IGameInstance> value = reader.readObjectCollection(new ArrayList<IGameInstance>(), true, false, new GameInstanceSerializer());
		return value;
	}

	@Override
	public void writeReturnValue(IDataWriter writer, List<IGameInstance> value) throws IOException {
		writer.writeObjectCollection(value, true, false, new GameInstanceSerializer());
	}

	@Override
	public IExecutableCommand<List<IGameInstance>> readRequest(IDataReader reader) throws IOException {

		// Read fields

		// Create object
		GetGameInstances object = new GetGameInstances();
		return object;
	}

	@Override
	public void writeRequest(IDataWriter writer, IExecutableCommand<List<IGameInstance>> argument) throws IOException {
		GetGameInstances object = (GetGameInstances) argument;

		// Get fields

		// Write fields
	}

	@Override
	public IExecutableCommandResponse<List<IGameInstance>> newResponse() {
		return new GetGameInstancesResponse();
	}
}
